package com.baidumap.administrator.happystudy.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.baidumap.administrator.happystudy.R;
import com.baidumap.administrator.happystudy.adapter.TypeLeftAdapter;
import com.baidumap.administrator.happystudy.adapter.TypeRightAdapter;


/**
 * 分类
 */
public class Fragment2 extends Fragment {

    private View view;
    private ListView lvLeft;
    private ListView lvRight;
    private TypeLeftAdapter mLeftAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fg2, container, false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        lvLeft = (ListView) view.findViewById(R.id.lv_left);
        lvRight = (ListView) view.findViewById(R.id.lv_right);

        lvRight.setAdapter(new TypeRightAdapter(getActivity()));

        mLeftAdapter = new TypeLeftAdapter(getActivity());
        lvLeft.setAdapter(mLeftAdapter);
        lvLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                mLeftAdapter.changeSelected(position);
            }
        });

    }
}
